# Copyright 2009-2011 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

include $(GOROOT)/src/Make.inc

TARG=godeit/go/parser

GOFILES=\
	lex.go\
	nodes.go\
	parser.go\
	scanner.go\
	yacc.go\

CLEANFILES += lex.yy.go yacc.tab y.output y.tab.c lex.go yacc.go y.go *~

include $(GOROOT)/src/Make.pkg

nodes.go: nodes lex.go parser.go scanner.go yacc.go
	./mknodes

lex.go: lex.l
	@if which golex ; \
		then golex -t lex.l | gofmt > lex.go ; \
	else \
		echo 'golex required' && \
		echo 'please install it with "goinstall github.com/cznic/golex"' && false ; \
	fi

yacc.go: yacc.y
	goyacc -l -v yacc.tab -o yacc.go yacc.y
	sed -i -e 's|//line.*||' -e 's/^func yyParse(yylex yyLexer) int {/func yyParse(yylex *lexer) int {/' yacc.go
	gofmt -w yacc.go
